home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DOS.SWG / 0001_Reboot with cache flush.pas next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  4.3 KB  |  151 lines

  1. ;-------------------------
  2. ; REBOOT.ASM   ver 192.5.1beta  ;-)
  3. ; Public domain from James Vahn, flush routines from Tim Arheit.
  4. ; "oh no!!" idea stolen from David Kirschbaum. 
  5.  
  6. cseg segment
  7. assume cs:cseg,ds:cseg
  8. org 100h
  9.  
  10. Begin:
  11.         mov cx,100d             ;close everything in sight
  12. Close_Lup:                      ;Loop to close first 100 possible
  13.         mov ah,03Eh             ;open files.
  14.         mov bx,cx
  15.         int 21h
  16.         loop Close_Lup
  17.  
  18.         mov ax,cs               ;Set DS to code segment.
  19.         mov ds,ax
  20.         mov ax,5D01h            ;Flush buffers and update directory
  21.         mov dx,offset Params    ;entries. This call may have problems
  22.         int 21h                 ;under OS/2 and DR-DOS..
  23.  
  24.         mov ah,0Dh              ;DOS flush file buffers.
  25.         int 21h                 ;Most cache programs catch this call.
  26.  
  27.         mov ah,21h              ;flush for QCASHE
  28.         int 13h
  29.  
  30.         mov ah,0A1h             ;flush for PC Kwik, PC-Cache v5
  31.         mov si,4358h            ;Qcache v4
  32.         int 13h
  33.  
  34.         mov ax,0FFA5h           ;flush for PC-Cache v6+
  35.         mov cx,0DDDDh
  36.         int 16h
  37.  
  38.         mov ax,0FE03h           ;flush for Norton Utilities NCACHE
  39.         mov di,"NU"
  40.         mov si,"CF"
  41.         int 2Fh
  42.  
  43.         mov ax,4A10h            ;flush for SMARTDRV v4.00+ -API
  44.         mov bx,0002h
  45.         int 2Fh
  46.  
  47. ;-----------------
  48. ; Flushed. On with the resetting..
  49. ;
  50.         mov ax,40h              ;Set ES to BIOS data area.
  51.         mov es,ax
  52.         mov word ptr es:[72h],1234h   ;Remove this for cold boot.
  53.  
  54. ;-----------------
  55. ; First attempt at a reset. If 15/4F isn't supported, hopefully
  56. ; no harm will come.
  57. ;
  58.         mov dl,byte ptr es:[17h]
  59.         or  byte ptr es:[17h],0Ch     ;Simulates CTRL-ALT-DEL
  60.         mov ax,4F53h                  ;on some machines. PS/2?
  61.         int 15h
  62.         mov byte ptr es:[17h],dl
  63.  
  64. ;-----------------
  65. ; Second attempt. This jumps to 'Beep' via the CMOS shutdown byte
  66. ; and resets via the 8042 keyboard interface chip if present.
  67. ;
  68.         mov ax,cs                         ;Set DS to code segment.
  69.         mov ds,ax
  70.         mov word ptr es:[69h],ax          ;Prepare BIOS for PM
  71.         mov word ptr es:[67h],offset Beep ; style reset.
  72.         mov al,0Fh
  73.         out 70h,al
  74.         call Delay
  75.         mov al,0Ah                    ;Set CMOS for BIOS JMP.
  76.         out 71h,al
  77.         call Delay
  78.         mov al,0FEh                   ;Reset via 8042
  79.         out 64h,al
  80.         call Delay
  81.  
  82. ;------------------
  83. ; Failed.. No 8042!  Ye olde standard reboot. If CMOS is present,
  84. ; this will also jump to Beep.
  85.  
  86.         db  0EAh,0h,0h,0FFh,0FFh       ;jmp FFFF:0000
  87.  
  88. ;------------------
  89. ; Delay routine, approx 1/18.2 seconds
  90. ;
  91. Delay:
  92.         push    ds
  93.         mov     ax,0040h
  94.         mov     ds,ax
  95.         mov     al,ds:[006Ch]
  96.    lo1: cmp     al,ds:[006Ch]
  97.         je      lo1
  98.         pop     ds
  99.         ret
  100.  
  101. ;------------------
  102. ; If successful, the CMOS shutdown byte will cause a jump to here,
  103. ; making a tone and resetting via a triple exception error.
  104. ;
  105. Beep:
  106.         push cs
  107.         pop ds
  108.  
  109.         mov ax,0E07h            ; Make a Beep.
  110.         int 10h
  111.  
  112.         mov al,0B6h             ; Make another Beep.
  113.         out 43h,al
  114.         in al,61h
  115.         or al,3h
  116.         out 61h,al
  117.         mov al,82h
  118.         out 42h,al
  119.         mov al,9h
  120.         out 42h,al
  121.         mov cx, 02000h
  122.   lo2:  in al,04Fh
  123.         loop lo2
  124. .286p
  125.         lidt fword ptr cs:Table       ; Forces a CPU reset.
  126.         int 0
  127.  Table  df 0
  128.  msg    db 'Oh no!!!$'
  129.  Params db 0                          ; Dynamic, 22 bytes.
  130.  
  131. cseg ends
  132. end Begin
  133.  
  134. { ----------------------   CUT -------------------------------}
  135.  
  136. Cut the following to a seperate file.  Name it REBOOT.XX
  137. Use XX3402 to decode the following if you do not have TASM to build
  138. the above code.  The COM file will be created.
  139.  
  140. example :  XX3402 D reboot.xx
  141.  
  142.  
  143.  
  144. *XX3402-000212-190296--72--85-20361------REBOOT.COM--1-OF--1
  145. iKE+h1u9qQoVsjWAm6vMi+3RihA-nG4o1QoVh05B2vGVjZV1nFCsdTytrRrB3fU1zfxJHft4
  146. Ewoji--8ik6+nGysE+0Ck0P5-b6+B-6aWVML+0O+1VQ+19VHHwoJ7cUK3k0Am6vM7eBd+0P5
  147. -aQ+b+4k1yNku-A+g+faQSUA+91ytaHc-E1e++1zzlusE+0Cq8-g+1c4P+-oyVz11Vys-kvB
  148. 290qtYDYMEk1ta4kUiN0g+baEfY+6CFDsjki1k2Sl+5B+++++++++2xc64tj6G2V7+++
  149. ***** END OF BLOCK 1 *****
  150.  
  151.